package com.heifeng.cloudshelf.mvp.programme.adapter;

import android.content.Context;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.MultipleItemRvAdapter;
import com.heifeng.cloudshelf.mvp.model.ProgrammeSelectInfo;
import com.heifeng.cloudshelf.mvp.model.SpecMultipleEntity;
import com.heifeng.cloudshelf.mvp.programme.provider.DialogSpecItemProvider;
import com.heifeng.cloudshelf.mvp.programme.provider.SpecItemProvider;

import java.util.List;

/**
 * Created by admin on 2019/9/19.
 */

public class SpecMultipleItemRvAdapter extends MultipleItemRvAdapter<SpecMultipleEntity, BaseViewHolder> {
    public static final int TYPE_VIEW = 0;

    public static final int TYPE_VIEW_DIALOG= 1;

    private List<ProgrammeSelectInfo> infos;

    public SpecMultipleItemRvAdapter(Context context, @Nullable List<SpecMultipleEntity> data, List<ProgrammeSelectInfo> infos) {
        super(data);
        mContext = context;
        this.infos = infos;

        finishInitialize();
    }

    @Override
    protected int getViewType(SpecMultipleEntity specMultipleEntity) {
        //根据实体类判断并返回对应的viewType，具体判断逻辑因业务不同，这里这是简单通过判断type属性
        if (specMultipleEntity.type == SpecMultipleEntity.TYPE_VIEW) {
            return TYPE_VIEW;
        }else if (specMultipleEntity.type == SpecMultipleEntity.TYPE_VIEW_DIALOG) {
            return TYPE_VIEW_DIALOG;
        }
        return 0;
    }

    @Override
    public void registerItemProvider() {
        mProviderDelegate.registerProvider(new SpecItemProvider(mContext, infos));
        mProviderDelegate.registerProvider(new DialogSpecItemProvider(mContext, infos));
    }
}
